﻿#region 程序集 VanillaPsycastsExpanded, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null
// C:\code\MyMod\MOD\bin\this!!!!!!!1\1.4\Assemblies\VanillaPsycastsExpanded.dll
// Decompiled with ICSharpCode.Decompiler 7.1.0.6543
#endregion

using System.Collections.Generic;
using RI_Talisman;
using RimWorld;
using RimWorld.BaseGen;
using RimWorld.QuestGen;
using RimWorld.SketchGen;
using UnityEngine;
using Verse;

namespace WhoXiuXian
{
    public class RI_LayoutWorkerComplex_Talisman : LayoutWorkerComplex
    {
        public RI_LayoutWorkerComplex_Talisman(LayoutDef def)
            : base(def)
        {
        }

        private static readonly SimpleCurve EntranceCountOverAreaCurve = new SimpleCurve
        {
        new CurvePoint(0f, 1f),
        new CurvePoint(1000f, 1f),
        new CurvePoint(1500f, 2f),
        new CurvePoint(5000f, 3f),
        new CurvePoint(10000f, 4f)
        };

        protected override LayoutSketch GenerateSketch(StructureGenParams parms)
        {
            int entranceCount = GenMath.RoundRandom(EntranceCountOverAreaCurve.Evaluate(parms.size.Area));
            ComplexLayoutSketch obj = new ComplexLayoutSketch
            {
                wallStuff = RI_T_DefOfs.RI_Resource_BlackSteel,
                door = RI_T_DefOfs.RI_Building_AncientDoor
            };
            StructureLayout structureLayout = (obj.layout = RoomLayoutGenerator.GenerateRandomLayout(new CellRect(0, 0, parms.size.x, parms.size.z), 6, 6, 0.2f, null, null, entranceCount));
            obj.FlushLayoutToSketch();
            return obj;
        }

        public override Faction GetFixedHostileFactionForThreats()
        {
            if (Rand.Chance(base.Def.fixedHostileFactionChance))
            {
                if (Faction.OfInsects != null && Faction.OfMechanoids != null)
                {
                    if (!Rand.Bool)
                    {
                        return Faction.OfMechanoids;
                    }

                    return Faction.OfInsects;
                }

                if (Faction.OfInsects != null)
                {
                    return Faction.OfInsects;
                }

                return Faction.OfMechanoids;
            }

            return null;
        }

        public class ComplexLayoutSketch : LayoutSketch
        {
            protected override ThingDef GetWallStuff(int roomId)
            {
                return ThingDefOf.WoodLog;
            }

        }
    }
}